# Copyright (c) 2019 Presto Labs Pte. Ltd.
# Author: donggu

from experimental.prophet.ops import timeseries
from experimental.prophet.contrib.variable import last_valid


# Advance Decline Difference
def add(var_list, window_size='1d'):
  sum = 0
  for var in var_list:
    var = last_valid(var)
    yesterday_var = timeseries.time_shift(var, window_size)
    sum += (var > yesterday_var) - (yesterday_var > var)
  return sum


__all__ = ['add']
